﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Cotizav.CONEXION;
using Cotizav.PRESENTACION.Controls;


namespace Cotizav.PRESENTACION.Personas.Cliente
{
    public partial class RegistroCliente : Form
    {
        IURegistroCliente iuRegistro;
        CtrlClientes controlador;
        
        public RegistroCliente()
        {
            InitializeComponent();

            iuRegistro = new IURegistroCliente();
            controlador = new CtrlClientes();
        }

        private void RegistroCliente_Load(object sender, EventArgs e)
        {
            loadGridClientes();
        }

        public void loadGridClientes()
        {
            SplitContainer panelMaestro = panelRegistro.Controls["splitContainer1"] as SplitContainer;
            panelMaestro.Panel2.Controls.Add(iuRegistro);

            DataGridView dg = panelMaestro.Panel1.Controls["gridListObjetos"] as DataGridView;
            AutoCompleteTextbox completeTextBox = panelMaestro.Panel1.Controls["txtBuscarContains"] as AutoCompleteTextbox;
            //TextBox txt = panelMaestro.Panel1.Controls["txtBuscar"] as TextBox;
            List<CLIENTE> clientes = controlador.getListCliente();

            dg.DataSource = null;
            dg.DataSource = clientes;

            completeTextBox.AutoCompleteList = clientes.Select(x => x.razonSocial).ToList<string>();
            //AutoCompleteStringCollection source = new AutoCompleteStringCollection();
            //source.AddRange(clientes.Select(x => x.razonSocial).ToArray());            

            //txt.AutoCompleteCustomSource = source;
            //txt.AutoCompleteMode = AutoCompleteMode.Suggest;
            //txt.AutoCompleteSource = AutoCompleteSource.CustomSource;            
        }
    }
}
